package com.quan.system.common.mq.producer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.quan.common.base.constant.CommonConstant;
import com.quan.common.utils.RandomUitl;
import com.quan.system.entity.SystemUser;

/**
 * 消息生产端-测试
 * 
 * @author yhaoquan
 *
 */
@Component
public class TestMessageProducer02 {

	private Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	private RabbitTemplate rabbitTemplate;

	/**
	 * 发送日志消息
	 * 
	 * @param entity
	 */
	public void sender(SystemUser entity) {
		logger.info("-----------------------TestMessageProducer02>>>消息生产端----------------------------");
		// 发送消息(交换机 exchange, 路由键 routingKey, 消息体内容, 消息唯一ID)
		// 发送消息(交换机 exchange, 路由键 routingKey, 消息体内容, 消息唯一ID)
				this.rabbitTemplate.convertAndSend(
						CommonConstant.EXCHANGE_TOPIC_TEST,
						CommonConstant.QUEUE_TOPIC_TEST+".TestMessageConsumer02",
						entity, 
						new CorrelationData(RandomUitl.uuid()));
	}

}
